'use strict';

// App Module: the name AngularStore matches the ng-app attribute in the main <html> tag
// the route provides parses the URL and injects the appropriate partial page
//
var ngApp = angular.module('EasyMarket', ['ui.directives','ui.bootstrap','ngRoute']).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
      when('/store', {
        templateUrl: 'partials/store.htm',
        controller: appController 
      }).
      when('/products/:productSku', {
        templateUrl: 'partials/product.htm',
        controller: appController
      }).
      when('/cart', {
        templateUrl: 'partials/shoppingCart.htm',
        controller: appController
      }).
      when('/pedidos', {
        templateUrl: 'partials/pedidos.htm',
        controller: appController
      }).
      otherwise({
        redirectTo: '/store'
      });
}]);

//storeApp.factory.hizoEnter= function() {
//    console.log("hizo enter re loco");
//} 
//storeApp.factory.clear = function() {
//    console.log("limpiando el piso");
//} 


function NavBarCtrl($scope) {
    $scope.isCollapsed = true;
}

// create a data service that provides a store and a shopping cart that
// will be shared by all views (instead of creating fresh ones for each view).
ngApp.factory("DataService", function () {

    // create store
    var myStore = new store();
    
    var myProducts = EmApp.products;
    // create shopping cart
    var myCart = new shoppingCart("AngularStore");

    // return data object with store and cart
    return {
        store: myStore,
        cart: myCart,
        products: myProducts,
        EmApp: EmApp
    };
});
